<%@ page import="java.sql.Connection" %>
<%@ page import="java.sql.Statement" %>
<%@ page import="java.sql.ResultSet" %>
<%@ page import="java.sql.DriverManager" %><%--
  Created by IntelliJ IDEA.
  User: lenovo
  Date: 2018/4/3
  Time: 16:53
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
</head>
<body>
<%
    request.setCharacterEncoding("utf-8");

    String username = request.getParameter("username");
    String password = request.getParameter("password");
    //3+1
    Connection connection = null;
    Statement statement = null;
    ResultSet resultSet = null;

    String sql = "insert into t_users(username, password) " +
            "values('"+username+"','"+password+"')";
    Class.forName("com.mysql.jdbc.Driver");

    connection = DriverManager.getConnection(
            "jdbc:mysql://localhost:3306/sctu_javaweb_2018?serverTimezone=UTC",
            "root",
            "113223"
    );
    statement = connection.createStatement();
    statement.executeUpdate(sql);//插入数据就是更新

    statement.close();
    connection.close();

    out.write("<h1>add user successful!</h1>");
    out.write("<a href='userList.jsp'>返回列表</a>");

%>
</body>
<%@include file = "footer.jsp"%>//加入版权信息
<%--<jsp:include page="footer.jsp">
    <jsp:param name="year" value="2017">
    </jsp:param>--%>
</html>
